package com.example.back.dao;

import com.example.back.bean.PayOrderDetails;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface PayOrderDetailsDao {

    @Insert("insert into t_pay_order_details(userId,userName,createTime,orderNumber,transactionId,payType,amount,appId,mchId,description,prepaymentId,rechargeQuantity,state,payTime,quantityAfterOperation,ext1,ext2)" +
            "values(#{userId},#{userName},#{createTime},#{orderNumber},#{transactionId},#{payType},#{amount},#{appId},#{mchId},#{description},#{prepaymentId},#{rechargeQuantity},#{state},#{payTime},#{quantityAfterOperation},#{ext1},#{ext2})")
    public void insertPayOrderDetails(PayOrderDetails payOrderDetails);

    @Select("select * from t_pay_order_details where  orderNumber=#{orderNumber} and state=0")
    public PayOrderDetails selectPayOrderDetails(String orderNumber);

    @Select("select * from t_pay_order_details where  state=1")
    public List<PayOrderDetails> selectSuccessPayOrderDetails();

    @Select("select * from t_pay_order_details where  state=0")
    public List<PayOrderDetails> selectCancelPayOrderDetails();

    @Update("update t_pay_order_details set transactionId=#{transactionId},payTime=#{payTime},state=#{state} where userId=#{userId} and orderNumber=#{orderNumber} and state=0 ")
    public int updatePayOrderDetails(PayOrderDetails payOrderDetails);

}
